import Vue from 'vue'
import Router from 'vue-router'
import Home from './views/Home.vue'

Vue.use(Router)
const routerPush = Router.prototype.push
Router.prototype.push = function push(location) {
  return routerPush.call(this, location).catch(error=> error)
}
export default new Router({
  routes: [
    {
      path: '/',
      name: 'home',
      component: Home,
      meta: {
        title: '首页'
      }
    },
    {
      path: '/home',
      name: 'homes',
      component: Home,
      meta: {
        title: '首页'
      }

    },
    {
      path: '/home/sub',
      name: 'sub',
      component: () => import('./components/Home/Subscribe.vue'),
      meta: {
        title: '订阅'
      }
    },
    {
      path: '/home/more',
      name: 'more',
      component: () => import('./components/Home/MoreList.vue'),
      meta: {
        title: '历史回测'
      }
    },
    {
      path: '/home/statement',
      name: 'statement',
      component: () => import('./components/Home/statement.vue'),
      meta: {
        title: '服务声明'
      }
    },
    {
      path: '/home/contract',
      name: 'contract',
      component: () => import('./components/Home/contract.vue'),
      meta: {
        title: '合约提醒'
      }
    },
    {
      path: '/home/deviation',
      name: 'deviation',
      component: () => import('./components/Home/deviation.vue'),
      meta: {
        title: '背离提醒'
      }
    },
    {
      path: '/home/strategy',
      name: 'strategy',
      component: () => import('./components/Home/strategy.vue'),
      meta: {
        title: '策略跟单'
      }
    },
    {
      path: '/home/height',
      name: 'height',
      component: () => import('./components/Home/height.vue'),
      meta: {
        title: '高低提醒'
      },children:[
          {
            path:"/",
            // component: () => import('./components/Home/noData.vue'),
            component: () => import('./components/Home/tabContent.vue'),
            name:'tabContent',
            meta: {
              title: '高低提醒'
            },
          },
        {
          path:"noData",
          component: () => import('./components/Home/noData.vue'),
          name:'noData',
          meta: {
            title: '高低提醒'
          },
        },


      ]
    },
    {
      path:"/home/Search",
      component: () => import('./components/Home/search.vue'),
      name:'Search',
      meta: {
        title: '高低提醒'
      },
    },
    {
      path:"/home/Edit",
      component: () => import('./components/Home/Edit.vue'),
      name:'Edit',
      meta: {
        title: '高低提醒'
      },
    },
    {
      path: '/home/detail',
      name: 'detail',
      component: () => import('./components/Home/bannerDetail.vue'),
      meta: {
        title: '详情'
      }
    },
    {
      path: '/message',
      name: 'message',
      // route level code-splitting
      // this generates a separate chunk (about.[hash].js) for this route
      // which is lazy-loaded when the route is visited.
      component: () => import(/* webpackChunkName: "about" */ './views/Message.vue'),
      meta: {
        title: '提醒'
      },children:[
            {
                path:"/",
                // component: () => import('./components/Home/noData.vue'),
                component: () => import('./components/Message/noData.vue'),
                name:'MsgnoData',
                meta: {
                    title: '提醒'
                },
            },
            {
                path:"list",
                component: () => import('./components/Message/List.vue'),
                name:'list',
                meta: {
                    title: '提醒'
                },
            },


        ]
    },
    {
      path: '/task',
      name: 'task',
      // route level code-splitting
      // this generates a separate chunk (about.[hash].js) for this route
      // which is lazy-loaded when the route is visited.
      component: () => import(/* webpackChunkName: "about" */ './views/Task.vue'),
      meta: {
        title: '任务'
      },children:[
        {
          path:"/",
          // component: () => import('./components/Home/noData.vue'),
          component: () => import('./components/Task/Index.vue'),
          name:'index',
          meta: {
            title: '任务'
          },
        },
        {
          path:"share",
          component: () => import('./components/Task/Share.vue'),
          name:'share',
          meta: {
            title: '邀请好友'
          },
        },
            {
                path:"pay",
                component: () => import('./components/Task/Pay.vue'),
                name:'pay',
                meta: {
                    title: '订阅服务'
                },
            },


      ]
    },
    {
      path: '/my',
      name: 'my',
      // route level code-splitting
      // this generates a separate chunk (about.[hash].js) for this route
      // which is lazy-loaded when the route is visited.
      component: () => import(/* webpackChunkName: "about" */ './views/My.vue'),
      meta: {
        title: '我的'
      },children:[
        {
          path:"/",
          // component: () => import('./components/Home/noData.vue'),
          component: () => import('./components/My/Index.vue'),
          name:'index',
          meta: {
            title: '我的'
          },
        },
        {
          path:"contact",
          // component: () => import('./components/Home/noData.vue'),
          component: () => import('./components/My/Contact.vue'),
          name:'contact',
          meta: {
            title: '联系客服'
          },
        },
        {
          path:"integral",
          // component: () => import('./components/Home/noData.vue'),
          component: () => import('./components/My/Integral.vue'),
          name:'integral',
          meta: {
            title: '我的积分'
          }
        },
        {
          path: "detail",
          // component: () => import('./components/Home/noData.vue'),
          component: () => import('./components/My/IntegralDetail.vue'),
          name: 'detail',
          meta: {
            title: '我的积分'
          }
        },
        {
          path: "recharge",
          // component: () => import('./components/Home/noData.vue'),
          component: () => import('./components/My/Recharge.vue'),
          name: 'recharge',
          meta: {
            title: '兑换'
          }
        },
        {
          path: "exchange",
          // component: () => import('./components/Home/noData.vue'),
          component: () => import('./components/My/Exchange.vue'),
          name: 'exchange',
          meta: {
            title: '积分兑换'
          },children:[
            {
              path: "/",
              // component: () => import('./components/Home/noData.vue'),
              component: () => import('./components/My/Server.vue'),
              name: 'server',
              meta: {
                title: '积分兑换'
              }

            },
            {
              path: "number",
              // component: () => import('./components/Home/noData.vue'),
              component: () => import('./components/My/Number.vue'),
              name: 'number',
              meta: {
                title: '积分兑换'
              }

            }
          ]
        }
          ]
    },
    {
      path: '/live',
      name: 'live',
      // route level code-splitting
      // this generates a separate chunk (about.[hash].js) for this route
      // which is lazy-loaded when the route is visited.
      component: () => import(/* webpackChunkName: "about" */ './views/Live.vue'),
      meta: {
        title: '直播'
      }
    },
    {
      path: '/login',
      name: 'login',
      // route level code-splitting
      // this generates a separate chunk (about.[hash].js) for this route
      // which is lazy-loaded when the route is visited.
      component: () => import(/* webpackChunkName: "about" */ './views/Login.vue'),
      meta: {
        title: '登录'
      },children:[
        {
          path: '/',
          name: 'login',
          // route level code-splitting
          // this generates a separate chunk (about.[hash].js) for this route
          // which is lazy-loaded when the route is visited.
          component: () => import('./components/Login/Login.vue'),
          meta: {
            title: '登录'
          }
        },
        {
          path: 'register',
          name: 'register',
          // route level code-splitting
          // this generates a separate chunk (about.[hash].js) for this route
          // which is lazy-loaded when the route is visited.
          component: () => import('./components/Login/Register.vue'),
          meta: {
            title: '注册'
          }
        },
        {
          path: 'forget',
          name: 'forget',
          // route level code-splitting
          // this generates a separate chunk (about.[hash].js) for this route
          // which is lazy-loaded when the route is visited.
          component: () => import('./components/Login/ForgetPwd.vue'),
          meta: {
            title: '忘记密码'
          }
        }
      ]
    },
    // {
    //   path: '/sub',
    //   name: 'sub',
    //   component: () => import(/* webpackChunkName: "about" */ './components/Home/Subscribe.vue'),
    //   meta: {
    //     title: '订阅'
    //   }
    // }
  ]
  ,scrollBehavior(to,from,savedPosition){

    if(savedPosition){
      return savedPosition;
    }else{
      return {x:0,y:0}
    }


  },
})
